Dart spread operator
—
Dart
Dart supports the spread operator, which allows to insert multiple elements into a collection.
For instance, from the cascade I described yesterday, this
return someVariable.toList()
..add(anotherObject)
..addAll(anotherListOfObjects);
becomes
return [
...someVariable.toList(),
anotherObject,
...anotherListOfObjects
];
Even more concise and easier to read.
Leave a comment